﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace odinshrine
{
    class Pause:Mainmenu
    {
        public TimeSpan timer_pause = TimeSpan.Zero;
        GestionPhysics phys = new GestionPhysics();
        Texture2D reprendre, quitter, mainMenu;
        Rectangle reprendreRect, quitRect, mainMenuRect;
        int reprendreX = 300, reprendreY = 200, quitX = 300, quitY = 300, mainMenuX = 300, mainMenuY = 100;
        public static bool pause = false;
        bool clavierUpDown1 = false, clavierUpUp1 = false;
        int placePause = 0;

        //Initialise le menu Pause
        public void initPause(ContentManager content)
        {
            reprendre = content.Load<Texture2D>("Menu/reprendre");
            quitter = content.Load<Texture2D>("Menu/quitter");
            mainMenu = content.Load<Texture2D>("Menu/menu_principal");
            imgBouton = content.Load<Texture2D>("Menu/imgBouton");

            reprendreRect = new Rectangle(reprendreX, reprendreY, reprendre.Width, reprendre.Height);
            quitRect = new Rectangle(quitX, quitY, quitter.Width, quitter.Height);
            mainMenuRect = new Rectangle(mainMenuX, mainMenuY, quitter.Width, quitter.Height);
        }

        //Dessine le menu Pause
        public void drawPause(SpriteBatch spriteBatch, MouseState mouse)
        {
            spriteBatch.Draw(reprendre, new Vector2(reprendreX, reprendreY), Color.White);
            spriteBatch.Draw(mainMenu, new Vector2(mainMenuX, mainMenuY), Color.White);
            spriteBatch.Draw(quitter, new Vector2(quitX, quitY), Color.White);
            if (placePause == 3)
            {
                spriteBatch.Draw(imgBouton, new Vector2(quitX - 70, quitY), Color.White);
            }
            if (placePause == 2 )
            {
                spriteBatch.Draw(imgBouton, new Vector2(reprendreX - 70, reprendreY), Color.White);
            }
            if (placePause == 1)
            {
                spriteBatch.Draw(imgBouton, new Vector2(mainMenuX - 70, mainMenuY), Color.White);
            }
        }

        //Gere le menu Pause(entrée souris...)
        public void Gestion(Game1 game, ContentManager Content, MouseState mouse, KeyboardState clavier)
        {

                if (clavier.IsKeyUp(Keys.Down))
                {
                    clavierUpDown1 = true;
                }
                if (clavier.IsKeyUp(Keys.Up))
                {
                    clavierUpUp1 = true;
                }
                if (clavier.IsKeyDown(Keys.Down) && placePause != 3 && clavierUpDown1)
                {
                    placePause++;
                    clavierUpDown1 = false;
                }
                if (clavier.IsKeyDown(Keys.Up) && placePause != 1 && clavierUpUp1)
                {
                    placePause--;
                    clavierUpUp1 = false;
                }
            
            if (placePause == 1 && clavier.IsKeyDown(Keys.Enter))
            {
                Mainmenu.menu_on = true;
                pause = false;
                quitterRect.X = quitterX;
                quitterRect.Y = quitterY;
                jouerRect.X = jouerX;
                jouerRect.Y = jouerY;
                optionsRect.X = optionsX;
                optionsRect.Y = optionsY;
            }
            if (placePause == 2 && clavier.IsKeyDown(Keys.Enter))
            {
                pause = false;
            }
            if (placePause == 3 && clavier.IsKeyDown(Keys.Enter))
            {
                game.Exit();
            }
        }
    }
}

